import { Component, ViewChild } from '@angular/core';
import { NavParams, Events, AlertController, App, ModalController, NavController, Content, ActionSheetController } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { Config } from '../../../providers/config';
import { DomSanitizer } from '@angular/platform-browser';
import _ from 'lodash';
// import * as Highcharts from 'highcharts';

import { Common } from "../../../providers/common";
import {BcwHomeService} from "./home.service";

@Component({
  selector: 'page-bcw-home-detail',
  templateUrl: './detail.html',
  providers: [BcwHomeService]
})
export class BcwHomeDetailPage {
	moa_page_name: any = "page-bcw-home-detail";
  moa_page_explain: any = "BCW预警消息详情";

  dataList = null;

  constructor(
    public alertCtrl: AlertController,
    public app: App,
    public modalCtrl: ModalController,
    public navCtrl: NavController,
    public config: Config,
    private sanitizer: DomSanitizer,
    public events: Events,
    public storage: Storage,
    private common: Common,
    private actionSheetCtrl: ActionSheetController,
    private bcwHomeService: BcwHomeService,
    private navParams: NavParams
  ) {

    this.dataList = [];
    let params_data_list = this.navParams.get("dataList");

    if (params_data_list) {
      _.forEach(params_data_list, data => {
        // data["expand"] = false;
        // data["vc_result_desc"] = this.sanitizer.bypassSecurityTrustHtml(data["vc_result_desc"]);
        let temp = _.clone(data);
        temp["expand"] = true;
        temp["vc_result_desc"] = this.sanitizer.bypassSecurityTrustHtml(temp["vc_result_desc"]);
        this.dataList.push(temp);
      });
    }
  }

  ionViewDidEnter() {
    this.common.bindLinkersEvent("page-bcw-home-detail");
  }

  expandException(item) {
    item["expand"] = !item["expand"];
  }

}
